<?php
/**
 * Модель Профиля пользователя
 */
class UserProfileModel extends AbstractModel{
  protected $tableName = 'user_profile';

  protected $primaryKey = array('user_id');

  public  $columnTypes = array(
      'user_id'=>'uuid',
      'birth_date'=>'date',
      'hire_date'=>'date',
      'fire_date'=>'date',
  );

  public  $data = array(
      'user_id'=>'',
      'first_name'=>'',
      'middle_name'=>'',
      'last_name'=>'',
      'birth_date'=>NULL,
      'hire_date'=>NULL,
      'fire_date'=>NULL,
      'salary'=>0,
      'responsibilities'=>'',
      'about'=>'',
  );


	static public function getByUserID($id){
		$db = DBFacade::getConnection();
		$sql='
			SELECT * FROM user_profile WHERE user_id = ?
		';
    $dbh = $db->prepare($sql);
		$dbh->execute(array($id));
    $line = $dbh->fetch();
		if (!empty($line)) return new UserProfileModel($line);
		else return false;
	}


	
}


